package leftRotation;

import java.io.IOException;
import java.util.Scanner;

/**
 * Description:
 * <p>
 * Created by Kiba 2018/9/17
 */
public class LeftRotation {

    // Complete the rotLeft function below.
    static int[] rotLeft(int[] a, int d) {

        int[] temp = new int[d];

        System.arraycopy(a, 0, temp, 0, d);

        int arrayLength = a.length;

        for (int i = 0; i < arrayLength; i++) {
            if (i < arrayLength - d) {
                a[i] = a[i + d];
            } else {
                int indexInTemp = d - (arrayLength - i);
                a[i] = temp[indexInTemp];
            }
        }

        return a;
    }

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) throws IOException {
//        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("C:\\Users\\Kiba\\Desktop\\leftRotation.txt"));

        String[] nd = scanner.nextLine().split(" ");

        int n = Integer.parseInt(nd[0]);

        int d = Integer.parseInt(nd[1]);

        int[] a = new int[n];

        String[] aItems = scanner.nextLine().split(" ");
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

        for (int i = 0; i < n; i++) {
            int aItem = Integer.parseInt(aItems[i]);
            a[i] = aItem;
        }

        int[] result = rotLeft(a, d);

        for (int i : result) {
            System.out.print(i + ", ");
        }

//        for (int i = 0; i < result.length; i++) {
//            bufferedWriter.write(String.valueOf(result[i]));
//
//            if (i != result.length - 1) {
//                bufferedWriter.write(" ");
//            }
//        }
//
//        bufferedWriter.newLine();
//
//        bufferedWriter.close();

        scanner.close();
    }
}
